function deleteSubmit(action, id){
	if(confirm("您确认删除该数据？")) {
	    location.href="./" + action + "?id=" + id;
	}
}

// 删除多条记录
function deleteMany(action, subBox){
	
	var text = "";
	var count = 0;
	$("input[name='" + subBox + "']:checked").each(function() {
		text += $(this).val() + ",";
		count++;
	});

	if (text == "") {
		alert("请选择要删除的数据!");
	} else {
		var tempText = text.substring(0, text.length - 1);
		
		if(confirm("您确认删除该" + count + "行数据？")) {
		    location.href="./" + action + "?id=" + tempText;
		}
	}
}

//全选/全不选
function mainCheck(mainBox, subBox) {
	$('input[name="' + subBox + '"]').attr("checked", $("#mainBox")[0].checked);
}

// 控制主Checkbox和子Checkbox之间的关系
function subCheck(mainBox, subBox) {
	
	var $subBoxObj = $("input[name='" + subBox + "']");
	var $checkValue = $subBoxObj.length == $("input[name='" + subBox + "']:checked").length ? true : false;
	$("#" + mainBox).attr("checked", $checkValue);
}

// 打开一个子页面，用来选取数据
function openwindow(url) {
	
	// var retval = window.showModalDialog("test.jsp?orderIds="+"0010,0020,0030",obj,"dialogWidth=500px;dialogHeight=500px");
	var retval = window.showModalDialog(
					url,
					window,
					"dialogHeight=360px;dialogWidth=560px;dialogTop=100px;dialogLeft=150px;toolbar=no;menubar=no;scroll=yes;resizable=no; location=no;status=no");

	// 解析此返回值
	if (retval == undefined) {
		retval = window.returnValue;
	}
	window.location.reload(true);

	// 赋值给对应的输入框
	//$('#enterpriseName').val(retval);
}

//打开一个子页面，关闭后刷新父页面
function openWinAndReload(url) {
	
	var retval = window.showModalDialog(
					url,
					window,
					"dialogHeight=360px;dialogWidth=560px;dialogTop=100px;dialogLeft=150px;toolbar=no;menubar=no;scroll=yes;resizable=no; location=no;status=no");

	// 解析此返回值
	if (retval == undefined) {
		retval = window.returnValue;
	}
	window.location.reload();
}

// (选择工业企业)关闭子窗体，往父窗体返回值
function selectEnterprise(enterpriseName, enterpriseId) {
	
	var rtnValue = enterpriseName + "," + enterpriseId;
	// FireFox, Chrome
	// 取得父窗体的值：$('#enterpriseName', window.opener.document).val()
	if (window.opener != undefined) {
		$('#enterpriseName', window.opener.document).val(enterpriseName)
		$('#enterpriseId', window.opener.document).val(enterpriseId)
		window.opener.returnValue = rtnValue;
	
	// IE
	// 取得父窗体的值：$('#enterpriseName', window.dialogArguments.document).val()
	} else {
		
		$('#enterpriseName', window.dialogArguments.document).val(enterpriseName);
		$('#enterpriseId', window.dialogArguments.document).val(enterpriseId);
		window.returnValue = rtnValue;
	}
	
	window.close();
}

function addProcessRow(index) {
	
   var date = $("#date").val();
   var process = $("#process").val();
   
   if (date == "") {
		alert("请输入时间")
		return;
	}

	if (process == "") {
		alert("请输入进展情况")
		return;
	}
   
	// 创建tr节点
   var $tr=$("<tr></tr>");
   var $td1 = $('<td width="25%" height="30" align="center" bgcolor="#FFFFFF" class="STYLE1"></td>');
   var $td2 = $('<td width="65%" height="30" align="center" bgcolor="#FFFFFF" class="STYLE1"></td>');
   var $td3 = $('<td width="10%" height="30" align="center" bgcolor="#FFFFFF" class="STYLE1"><a href="#" class="del">删除</a></td>');
   
   $dateHidden = '<input type="hidden" name="buildingProject.processInfos[' + index + '].processDate" value="' + $("#date").val() + '"/>';
   $processHidden = '<input type="hidden" name="buildingProject.processInfos[' + index + '].process" value="' + $("#process").val() + '"/>';
   // 将内容添加到创建好的TD中
   $td1.append($dateHidden + date);
   $td2.append($processHidden + process);
   
   // 将td添加到创建好的TR中
   $td1.appendTo($tr);
   $td2.appendTo($tr);
   $td3.appendTo($tr);
   
   $tr.appendTo("#processtab");
   
   $("#date").val("");
   $("#process").val("");
    
   // 执行删除操作
   $(".del").click(function (){
	   delProcessRow($(this));
    });
}

function delProcessRow(event) {
	event.parent().parent().remove();
}

function showsubmenu(sid) {
	
	whichEl = eval("submenu" + sid);
	imgmenu = eval("imgmenu" + sid);
	if (whichEl.style.display == "none") {
		eval("submenu" + sid + ".style.display=\"\";");
		imgmenu.background = "images/main_47.gif";
	} else {
		eval("submenu" + sid + ".style.display=\"none\";");
		imgmenu.background = "images/main_48.gif";
	}
}

function switchSysBar() {
	var locate = location.href.replace('middel.jsp', '');
	var ssrc = document.all("img1").src.replace(locate, '');
	if (ssrc == "images/main_55.gif") {
		document.all("img1").src = "images/main_55_1.gif";
		document.all("frmTitle").style.display = "none"
	} else {
		document.all("img1").src = "images/main_55.gif";
		document.all("frmTitle").style.display = ""
	}
} 
